﻿@model LabManagement.Data.Org

@{
    ViewBag.Title = "Create";
}
@using (Html.BeginForm("Create", "Org", FormMethod.Post, new { @class = "form-horizontal form-bordered" }))
{
    @Html.ValidationSummary(true)
    <div class="box box-bordered">
        <div class="box-title">
            <h3>
                <i class="fa fa-th-list"></i>Organization
            </h3>
        </div>
        <div class="box-content nopadding">
            @Html.AntiForgeryToken()
            <div class="form-group">
                @Html.LabelFor(model => model.OrgName, new { @class = "control-label col-sm-2" })
                <div class="col-sm-10">
                    @Html.TextBoxFor(model => model.OrgName, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.OrgName)
                </div>
            </div>
        </div>
    </div>
    <div class="box box-bordered">
        <div class="box-title">
            <h3>
                <i class="fa fa-th-list"></i>Organization Contact
            </h3>
        </div>
        <div class="box-content nopadding">
            @Html.AntiForgeryToken()
            <div class="form-group">
                @Html.Label("Name", new { @class = "control-label col-sm-2" })
                <div class="col-sm-4">
                    @Html.TextBoxFor(model => model.Contact.ContactFirstName, new { @class = "form-control ", placeholder = "First Name" })

                </div>
                <div class="col-sm-2">
                    @Html.TextBoxFor(model => model.Contact.ContactMiddleName, new { @class = "form-control ", placeholder = "Middle Name" })
                </div>
                <div class="col-sm-4">
                    @Html.TextBoxFor(model => model.Contact.ContactLastName, new { @class = "form-control ", placeholder = "Last Name" })
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Email", new { @class = "control-label col-sm-2" })
                <div class="col-sm-10">
                    @Html.TextBoxFor(model => model.Contact.ContactEmail, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.OrgPrimaryContactId)
                </div>
            </div>
            <div class="form-group multiple-form-group">
                @Html.Label("Phones", new { @class = "control-label col-sm-2" })
                <div class="col-sm-10">
                    <div class="container" id="phones">

                    </div>
                    <a class="btn btn-primary AddPhone">Add Phone</a>
                </div>
            </div>
        </div>
    </div>
    <div class="box box-bordered ">
        <div class="box-title">
            <h3>
                <i class="fa fa-th-list"></i>Addresses 
            </h3>          
            <a class="btn btn-primary AddAddress">Add Address</a>
        </div>
        <div class="box-content AddAddressContainer">

        </div>
        </div>
    <div class="form-actions">
        <button type="submit" class="btn btn-primary">Save </button>
        @Html.ActionLink("Cancel", "Index", null, new { @class = "btn" })
    </div>
}
@section Scripts{
    <script type="text/javascript">
        var phoneAdded = 0;
        var addressAdded = 0;
        $(".AddPhone").on("click", function () {
            $.get('@Url.Action("AddPhone")/' + phoneAdded, function (html) {               
                $(html).appendTo("#phones");
                phoneAdded = phoneAdded + 1;
            })
        });
        $(".AddAddress").on("click", function () {
            $.get('@Url.Action("AddAddress")/' + addressAdded, function (html) {
                $(html).appendTo(".AddAddressContainer");
                addressAdded = addressAdded + 1;
            })
        });
    </script>
}